<template>
  <div class="hospitalInfoCss">
    <div class="titleCss">【测试数据】苏应坤中医诊所</div>
    <div class="smallTitleCss">
      <span>中医（综合）诊所</span>
    </div>
    <div class="bodyCss">
      <div class="customTableCss" style="padding-bottom: 25px;border-bottom: 1px solid #f2f2f2;">
        <table border="1">
          <tbody>
            <tr>
              <td class="tableLabelCss">所在镇/街道</td>
              <td>菁城街道</td>
              <td class="tableLabelCss">联系电话</td>
              <td>18888888888</td>
            </tr>
            <tr>
              <td class="tableLabelCss">执业范围</td>
              <td colspan="3">医疗与护理保健、全科诊疗与护理、医学教学、卫生医疗、医学研究</td>
            </tr>
            <tr>
              <td class="tableLabelCss">诊疗科目</td>
              <td colspan="3">预防保健科、内科、外科；整形外科、眼科、医学检验科、麻醉科、医学影像科</td>
            </tr>
            <tr>
              <td class="tableLabelCss">详细地址</td>
              <td colspan="3">【测试数据】福建省漳平市赤山路79号</td>
            </tr>
            <tr>
              <td class="tableLabelCss">医生人数</td>
              <td>3</td>
              <td class="tableLabelCss">护士人数</td>
              <td>3</td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="bodyTitleCss">证件信息</div>
      <CertInfoCard/>
      <div class="bodyTitleCss">人员信息</div>
      <PersonInfoCard/>
      <div class="bodyTitleCss">日常检查任务记录</div>
      <div class="tableCss">
        <el-table
          max-height="200"
          :data="tableData1"
          border
          style="width: 100%">
          <el-table-column
            prop="data1"
            label="检查专业"
            min-width="100">
          </el-table-column>
          <el-table-column
            prop="data2"
            label="监督机构"
            min-width="100">
          </el-table-column>
          <el-table-column
            prop="data3"
            label="执行状态"
            min-width="100">
          </el-table-column>
          <el-table-column
            prop="data4"
            label="报告日期"
            min-width="100">
          </el-table-column>
        </el-table>
      </div>
      <div class="bodyTitleCss">抽查任务记录</div>
      <div class="tableCss">
        <el-table
          max-height="200"
          :data="tableData2"
          border
          style="width: 100%">
          <el-table-column
            prop="data1"
            label="检查专业"
            min-width="100">
          </el-table-column>
          <el-table-column
            prop="data2"
            label="监督机构"
            min-width="100">
          </el-table-column>
          <el-table-column
            prop="data3"
            label="执行状态"
            min-width="100">
          </el-table-column>
          <el-table-column
            prop="data4"
            label="报告日期"
            min-width="100">
          </el-table-column>
        </el-table>
      </div>
      <div class="bodyTitleCss">双随机公开任务记录</div>
      <div class="tableCss">
        <el-table
          max-height="200"
          :data="tableData3"
          border
          style="width: 100%">
          <el-table-column
            prop="data1"
            label="检查专业"
            min-width="100">
          </el-table-column>
          <el-table-column
            prop="data2"
            label="监督机构"
            min-width="100">
          </el-table-column>
          <el-table-column
            prop="data3"
            label="执行状态"
            min-width="100">
          </el-table-column>
          <el-table-column
            prop="data4"
            label="报告日期"
            min-width="100">
          </el-table-column>
        </el-table>
      </div>
      <div class="bodyTitleCss">行政处罚记录</div>
      <div class="tableCss">
        <el-table
          max-height="200"
          :data="tableData4"
          border
          style="width: 100%">
          <el-table-column
            prop="data1"
            label="处罚类型"
            min-width="100">
            <template #default="scope">
              {{ table4data1Map[scope.row.data1] }}
            </template>
          </el-table-column>
          <el-table-column
            prop="data2"
            label="处罚金额"
            min-width="100">
            <template #default="scope">
              {{ scope.row.data2 ? scope.row.data2 : '-' }}
            </template>
          </el-table-column>
          <el-table-column
            prop="data3"
            label="处罚日期"
            min-width="100">
          </el-table-column>
          <el-table-column
            prop="data4"
            label="是否整改完成"
            min-width="100">
            <template #default="scope">
              {{ table4data4Map[scope.row.data4] }}
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div class="bottomBtnCss">
      <el-button @click="goBackBtn">返回</el-button>
    </div>
  </div>
</template>

<script>
import CertInfoCard from '@/views/components/pages/certInfoCard/index.vue'
import PersonInfoCard from '@/views/components/pages/personInfoCard/index.vue'
import { getCurrentDay } from '@/utils/business.js'
export default {
  components:{ CertInfoCard , PersonInfoCard},
  data(){
    return{
      mp4Url:'',
      tableData1:[],
      tableData2:[],
      tableData3:[],
      tableData4:[],
      table4data1Map:{
        0:'警告',
        1:'罚款',
        2:'没收违法所得',
        3:'责令停产停业',
        4:'吊销许可证',
      },
      table4data4Map:{
        0:'是',
        1:'否',
      },
    }
  },
  mounted(){
    this.getList()
  },
  methods:{
    goBackBtn(){
      this.$router.back()
    },
    getList(){
      const random = Math.floor( Math.random() * 10) + 5
      let list4 = []
      let list = []
      for( let i=0;i<random;i++){
        const random41 = Math.floor( Math.random() * 5)
        const random42 = Math.floor( Math.random() * 2)
        const random43 = Math.floor( Math.random() * 999999)
        const random44 = Math.floor( Math.random() * 2)
        list4.push({
          data1: random41,
          data2: Boolean( random42 ) ? '' : random43.toLocaleString('en-US'),
          data3: getCurrentDay(),
          data4: random44,
        })
        list.push({
          data1: '【测试数据】医疗卫生',
          data2: '【测试数据】漳平市卫生监督所',
          data3: '【测试数据】未发现问题',
          data4: getCurrentDay(),
        })
      }
      this.tableData1 = list
      this.tableData2 = list
      this.tableData3 = list
      this.tableData4 = list4
    },
    changeNumFun(num){
      const numMap = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
      const unitMap = ['', '十', '百', '千', '万', '十万', '百万', '千万', '亿'];
      if (num === 0) {
        return numMap;
      }
      let chineseStr = ''
      let unitPos = 0
      let zero = true
      while (num > 0) {
          let digit = num % 10;
          if (digit === 0) {
              if (!zero) {
                  zero = true;
                  chineseStr = numMap[digit] + chineseStr;
              }
          } else {
              zero = false;
              chineseStr = numMap[digit] + unitMap[unitPos] + chineseStr;
          }
          unitPos++;
          num = Math.floor(num / 10);
      }
      if (chineseStr.startsWith('一十')) {
          chineseStr = chineseStr.substring(1);
      }
      return chineseStr.replace(/零+/g, '零')
    },
  },
}
</script>

<style lang="scss" scoped>
.hospitalInfoCss{
  overflow: hidden;
  position: relative;
  background-color: #fff;
  padding: 20px;
  border-radius: 10px;
  height: calc( 100vh - 66px - 40px);
  display: flex;
  flex-direction: column;
  .titleCss{
    text-align: center;
    font-size: 24px;
    font-weight: bold;
  }
  .smallTitleCss{
    font-size: 18px;
    margin-top: 10px;
    text-align: center;
  }
  .bodyCss{
    margin-top: 20px;
    margin-left: 20px;
    width: calc( 100% - 10px);
    padding-right: 40px;
    overflow-y: auto;
    height: calc( 100% - 140px);
    padding-bottom: 20px;
    .customTableCss{
      table {
        border-collapse: collapse;
        width: 100%;
        line-height: 34px;
        &:not(:first-child){
          margin-top: 15px;
        }
        .tableLabelCss{
          font-weight: bold;
        }
        .tableValueCss{
          color: green;
          width: 200px;
          text-align: center;
          font-weight: bold;
        }
      }
      th, td {
        border: 1px solid black;
        padding: 8px;
        text-align: left;
      }
      th {
        background-color: #f2f2f2;
      }
      tr:last-child td {
        border-bottom: none;
      }
      td:nth-child(2) {
        border-right: none;
      }
    }
    .bodyTitleCss{
      text-align: center;
      font-size: 24px;
      font-weight: bold;
      margin-top: 20px;
    }
    .tableCss{
      padding-bottom: 20px;
      margin-top: 20px;
    }
  }
  .bottomBtnCss{
    margin-top: auto;
    text-align: right;
  }
}
</style>